package numberporting.service;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jws.WebService;
import numberporting.bean.*;
/**
 *
 * @author hahnepeter
 */
@WebService(targetNamespace="http://infosys.tuwien.ac.at/ait08/dto/notification",
            portName="NotificationPT", serviceName="NotificationService", endpointInterface="numberporting.service.INotificationService")
public class MailService implements INotificationService {
    private CustomerStore customerStore;
    
    public MailService(CustomerStore customerStore){
        this.customerStore = customerStore;
    }
    @Override
    public boolean notify_customer(Customer customer, String message) throws InvalidCustomerException{
        System.out.println("Mail customer notification triggered! message: "+message);
        this.customerStore.checkCustomer(customer.getId());
        try {
            Thread.sleep(30 * 1000);
        } catch (InterruptedException ex) {
            Logger.getLogger(MailService.class.getName()).log(Level.SEVERE, null, ex);
        }
        return (Math.random() < 0.5);
    }
}
